package com.njit.campuslifeboot.service.impl;

import com.njit.campuslifeboot.entity.dto.LifeInfoDTO;
import com.njit.campuslifeboot.entity.dto.ListDTO;
import com.njit.campuslifeboot.entity.po.LifeInfo;
import com.njit.campuslifeboot.mapper.LifeInfoMapper;
import com.njit.campuslifeboot.service.ILifeInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Axin
 * @since 2022-11-07
 */
@Service
public class LifeInfoServiceImpl extends ServiceImpl<LifeInfoMapper, LifeInfo> implements ILifeInfoService {

    @Autowired
    private LifeInfoMapper lifeInfoMapper;

    @Override
    public boolean addLifeInfo(LifeInfoDTO lifeInfoDTO, Integer userId, Integer power) {
        LifeInfo lifeInfo = new LifeInfo();
        lifeInfo.setMessageInfo(lifeInfoDTO.getMessageInfo());
        lifeInfo.setUserId(userId);
        lifeInfo.setPower(power);
        lifeInfo.setCreateTime(LocalDateTime.now());
        int insert = lifeInfoMapper.insert(lifeInfo);
        return insert > 0;
    }

    @Override
    public List<ListDTO> getLifeList(LifeInfoDTO lifeInfoDTO, Integer userId) {
        List<ListDTO> lifeList = lifeInfoMapper.getLifeList(lifeInfoDTO, userId);
        return lifeList;
    }

    @Override
    public List<ListDTO> getLifeListPrivate(LifeInfoDTO lifeInfoDTO, Integer userId) {
        List<ListDTO> lifeList = lifeInfoMapper.getLifeListPrivate(lifeInfoDTO,userId);
        return lifeList;
    }

    @Override
    public List<ListDTO> getSomeOneLifeList(LifeInfoDTO lifeInfoDTO) {
        List<ListDTO> lifeList = lifeInfoMapper.getSomeOneLifeList(lifeInfoDTO);
        return lifeList;
    }

    @Override
    public List<ListDTO> getFriendsLife(List<String> ids) {
        List<ListDTO> lifeList= lifeInfoMapper.getFriendsLife(ids);
        return lifeList;
    }
}
